package top.soulblack.purchasesale.controller.wechat;

import ch.qos.logback.core.net.server.Client;
import com.alibaba.druid.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.util.ResourceUtils;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;


import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.util.LinkedHashMap;
import java.util.Map;

@Component
public class BaseController {
    @Autowired
    protected HttpServletRequest request;

    protected String error(Model model,String msg, String url) {
        model.addAttribute("code",0);
        model.addAttribute("msg",msg);
        model.addAttribute("url",url);
        return "wechat/index/error";
    }

    protected String error(Model model,String msg){
        return error(model,msg,"javascript:pageManager.back();");
    }

    protected String success(Model model,String msg, String url){
        model.addAttribute("code",1);
        model.addAttribute("msg",msg);
        model.addAttribute("url",url);
        return "wechat/index/success";
    }

    protected String success(Model model,String msg){
        return success(model,msg,"javascript:pageManager.back();");
    }
}